/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vinisoft.gymwebapp.view;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.primefaces.context.RequestContext;

/**
 *
 * @author Vinicio Enrique Mercado Moreno
 * @version 2.0
 */
public abstract class AbstractJSFManagedBean {

    protected static final Logger logger = Logger.getGlobal();
// =============================================================================

    protected void _init() {
        logger.log(Level.INFO, "Creando instancia [{0}]", getClass().getCanonicalName());
    }

    public String inicio$action() {
        return "/app/inicio?faces-redirect=true";
    }

    public void mostrarMensajeJSF(FacesMessage.Severity severidad, String mensaje) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severidad, null, mensaje));
    }

    public void mostrarDialogo(String dialogo) {
        RequestContext.getCurrentInstance().execute(new StringBuilder(dialogo).append(".show();").toString());
    }

    public void ocultarDialogo(String dialogo) {
        RequestContext.getCurrentInstance().execute(new StringBuilder(dialogo).append(".hide();").toString());
    }
}
